cairoblur: Move the check for early exit
authorBenjamin Otte <otte@redhat.com>
Wed, 12 Feb 2020 23:14:29 +0000 (00:14 +0100)
committerBenjamin Otte <otte@redhat.com>
Thu, 13 Feb 2020 06:36:38 +0000 (07:36 +0100)
That means we only have one place where we check all kinds of early
exits.

gsk/gskcairoblur.c
gsk/gskrendernodeimpl.c

index 6b5a3d56df29d66f5feef61ec381d8b619718e39..fd83470f6a8202eb8f5930824435dfb92b3768f6 100644 (file)
@@ -281,8 +281,13 @@ gsk_cairo_blur_compute_pixels (double radius)
 }
 
 static gboolean
-needs_blur (float radius)
+needs_blur (float        radius,
+            GskBlurFlags blur_flags)
 {
+  /* Neither blurring horizontal nor vertical means no blurring at all. */
+  if ((blur_flags & (GSK_BLUR_X | GSK_BLUR_Y)) == 0)
+    return FALSE;
+
   /* The code doesn't actually do any blurring for radius 1, as it
    * ends up with box filter size 1 */
   if (radius <= 1.0)
@@ -306,7 +311,7 @@ gsk_cairo_blur_start_drawing (cairo_t         *cr,
   gboolean blur_x = (blur_flags & GSK_BLUR_X) != 0;
   gboolean blur_y = (blur_flags & GSK_BLUR_Y) != 0;
 
-  if (!needs_blur (radius))
+  if (!needs_blur (radius, blur_flags))
     return cr;
 
   gdk_cairo_get_clip_rectangle (cr, &clip_rect);
@@ -372,7 +377,7 @@ gsk_cairo_blur_finish_drawing (cairo_t         *cr,
   cairo_surface_t *surface;
   gdouble x_scale;
 
-  if (!needs_blur (radius))
+  if (!needs_blur (radius, blur_flags))
     return cr;
 
   original_cr = cairo_get_user_data (cr, &original_cr_key);
index 43844cd1e2df07f0e547b95ba3618bf6dbf1d3cf..e35fd1b44aeea6d092b35a18ac31449fd713dced 100644 (file)
@@ -770,17 +770,12 @@ draw_shadow (cairo_t             *cr,
             GskBlurFlags         blur_flags)
 {
   cairo_t *shadow_cr;
-  gboolean do_blur;
 
   if (has_empty_clip (cr))
     return;
 
   gdk_cairo_set_source_rgba (cr, color);
-  do_blur = (blur_flags & (GSK_BLUR_X | GSK_BLUR_Y)) != 0;
-  if (do_blur)
-    shadow_cr = gsk_cairo_blur_start_drawing (cr, radius, blur_flags);
-  else
-    shadow_cr = cr;
+  shadow_cr = gsk_cairo_blur_start_drawing (cr, radius, blur_flags);
 
   cairo_set_fill_rule (shadow_cr, CAIRO_FILL_RULE_EVEN_ODD);
   gsk_rounded_rect_path (box, shadow_cr);
@@ -791,8 +786,7 @@ draw_shadow (cairo_t             *cr,
 
   cairo_fill (shadow_cr);
 
-  if (do_blur)
-    gsk_cairo_blur_finish_drawing (shadow_cr, radius, color, blur_flags);
+  gsk_cairo_blur_finish_drawing (shadow_cr, radius, color, blur_flags);
 }
 
 typedef struct {